/*  =========================================================================
    zmtp_selftest - run self tests

    Copyright (c) contributors as noted in the AUTHORS file.
    This file is part of libzmtp, the C ZMTP stack.

    This Source Code Form is subject to the terms of the Mozilla Public
    License, v. 2.0. If a copy of the MPL was not distributed with this
    file, You can obtain one at http://mozilla.org/MPL/2.0/.
    =========================================================================
*/

#include "zmtp_classes.h"
#include "MemPool.h"

int main(int argc, char *argv [])
{
//    bool verbose;
//    if (argc == 2 && strcmp (argv [1], "-v") == 0)
//        verbose = true;
//    else
//        verbose = false;
//
//    printf ("Running self tests...\n");
//    zmtp_msg_test (verbose);
//    printf ("Tests passed OK\n");

    MemPoolItem itemsSharedBuffer[] = {{10, 64, NULL}, {10, 128, NULL}, {10, 2560, NULL}};
    cmemPoolSet = CMemPoolSet_New(itemsSharedBuffer, 3);
    //void *p = CMemPoolSet_Alloc(cmemPoolSet, 10, MUST_USE_MEM_POOL);

    //zmtp_msg_test(false);
    //zmtp_channel_test(false);

    //zmtp_dealer_test和zmtp_connect_test功能相似，启用其一即可
    //目前唯一区别：
    //zmtp_dealer_test固定了IP和端口(127.0.0.1:4800)
    //zmtp_connect_test手动输入IP和端口，格式: tcp://IP:port

    //2024.5.24：目前zmtp_connect_test()之外的test编译不通过，暂且仅保留zmtp_connect_test()，今后修复

    if (argc !=2){
        //zmtp_dealer_test(false);
        printf("Use \"./libzmtp_selftest tcp://<IP:port> \" to customize IP & port of the test.\n");
    } else {
        zmtp_connect_test((const char*) *(++argv));
    }

    return 0;
}
